<template>
	<view class="container">
		<view v-for="(item,index) in courseList" :key="item.newsId" class="classlistcont" @tap="goVideoplay(item.newsId)">
			<view class="imgCont"><image :src="item.pPic"></image></view>
			<view class="classdetailCont">
				<text class="classtitle">{{item.title}}</text>
				<view class="classdetail">{{item.newsAbstract}}</view>
				<text class="classfee">免费学习</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { request } from "@/http/request"
	import { newsServlet,latestRecord  } from "@/http/api.js"
	export default {
		data() {
			return {
				nodeId: 169,
				loadnum: 10,
				isLoading: false,
				touchbottomCount: 1,
				courseList: []
			}
		},
		// onPageScroll:function(e){
		// 	if(this.previousScrollDis==""){
		// 		this.previousScrollDis=e.scrollTop;
		// 	}else{
		// 		if(this.previousScrollDis>e.scrollTop){
		// 			console.log("向上滚动");
		// 		}else if(this.previousScrollDis<e.scrollTop){
		// 			console.log("向下滚动");
		// 		}
		// 		this.previousScrollDis=e.scrollTop;
		// 	} 
		// },
		onLoad(e){
			console.log('--------onLoad--------');
			if(e&&e.content){
				let _obj = JSON.parse(decodeURIComponent(e.content));
				this.nodeId = _obj.id;
				this.getCourseList()
			}
		},
		methods: {
			// 课程列表
			getCourseList(){
				console.log('--------getCourseList--------');
				const _data = {
					url: newsServlet,
					data: {
						functionName: 'getCurrentNodeNews',
						nodeId: this.nodeId
					}
				};
				request(_data).then( res => {
					this.isLoading = true
					this.courseList.push.apply(this.courseList, res.data)
					if (res.data.length >= this.loadnum) return 
					this.isLoading = false
				})
			},
			goVideoplay(id){
				this.toAutorize()
				this.goPage('/pages/onlineschool/videoplay/index',{nodeId: this.nodeId,newsId: id})
			}
		}
	}
</script>

<style lang="scss">
	@import "./index.scss";
</style>
